package com.strongbj.iot.mq.producer;

import javax.jms.Destination;

import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

@Component("topicSender")
public class TopicSender {

	@Autowired
	private JmsMessagingTemplate jmsTemplate;
	
	/**
	 * 发送一条消息到指定的队列（目标）
	 * @param queueName 队列名称
	 * @param message 消息内容
	 */
	public void send(String topicName,final String message){
		Destination destination = new ActiveMQTopic(topicName);
        jmsTemplate.convertAndSend(destination, message);
	}

}
